<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div style="width: 50px;height: 50px;background-color: beige;">
    </div>
    <button id="btn">牛</button>

    <script>
        // 匿名函数
        // (function(i){
        //     console.log(i)
        // })(1)

        let btn = document.getElementById('btn'),
            divs = document.querySelector('div')
        console.log(divs)
        function interval(callback, delay) {
            let id = setInterval(() => {
                callback(id)
            }, delay);
        }


        // 先学习下getComputeStyle
        interval(function (id) {
            // let lefts = parseInt(window.getComputedStyle(divs).left)
            // console.log(lefts)
            divs.style.backgroundColor = 'red';
        }, 1000)
    </script>
</body>


</html>